{extend name="common/base" /}
{block name="body"}
<div style="padding: 0px 10px 0px 10px;">
<div class="layui-tab">
    <ul class="layui-tab-title">

        <li {eq name="type" value="uninstall"}class="layui-this"{/eq}> <a href="{:url('index',['type'=>'uninstall'])}">退出|还原</a></li>
        <li {eq name="type" value="notinstall"}class="layui-this"{/eq}><a href="{:url('index',['type'=>'notinstall'])}">安装|卸载</a></li>
    </ul>
</div>
<form class="layui-form" action="">
    <div class="layui-form-item">

        <div class="layui-form-item">
            <label class="layui-form-label">公众号权限</label>
            <div class="layui-input-block ">
                <div class="select-allmp">
                    <input type="checkbox"  title="全选公众号" lay-skin="primary" lay-filter="allChoose" id="selectAllMp">
                </div>

                {volist name="mpList" id="mp"}
                <div class="select-mplist {if condition='$mp.checked == 1'}on{/if} ">

                    <div class="logo-left">
                        <img src="{$mp.logo}">
                    </div>
                    <div class="logo-right" style="width: 112px;overflow: hidden;">
                        <p class="p1">{$mp.name}</p>
                        <p class="p2">类型：{$mp.type_name}</p>
                    </div>
                    <input type="checkbox" name="mp_power[{$mp.id}]" class="select-mp" value="{$mp.id}" {if condition="$mp.checked == 1"}checked{/if} lay-ignore>
                </div>
                {/volist}
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="updatepwd">确认更改</button>
            </div>
        </div>
    </div>
</form>
</div>
<script>
    layui.use('form', function () {
        var form = layui.form;
        form.on('submit(updatepwd)', function (data) {
            $.post('',data.field,function (res) {
                if(res.status=='0'){
                    layer.alert(res.msg);
                }else if(res.status=='1'){
                    layer.msg(res.msg,{time:1000},function () {
                        location.href="{:url('index')}";
                    });
                }
            })
            return false;
        });
        form.on('checkbox(allChoose)', function(data){

            if($(data.elem).prop("checked")) {

                $('.select-mplist').addClass('on');
                $('.select-mp').prop('checked', true);

            }else{
                $('.select-mplist').removeClass('on');
                $('.select-mp').prop('checked',false);
            }
            form.render('checkbox');
        });
    });
    $(function () {


        $('.select-mp').change(function () {
            if($(this).prop("checked")){
                $(this).parent('.select-mplist').addClass('on');
            }else{
                $(this).parent('.select-mplist').removeClass('on');
            }
        });

    })

</script>
{/block}